var loginUser = {
  getLoginUser: function () {
    console.log('util.getUser=======getLoginUser()');
   var loginUser=null;
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
        if (res.code) {
          console.log('userUtil.code==' + res.code)
          // 发起网络请求
          wx.request({
            url: 'https://www.zuoye123.com/n_cloudmate/weixin/getuserid',
            data: {
              code: res.code
            },
            header: {
              'content-type': 'application/json' // 默认值
            },
            success: function (data) {
              console.log('======userUtil===getLoginUser=============');
              console.log(data);
              if (data.data.errorCode == 0) {
                if (data.data.userId != 0) {
                  loginUser = data.data.loginUser[0];
                  console.log('==========userUtil=====loginUser================');
                  console.log(data.data.loginUser[0]);
                }
              } 
            }
          })
        }  
      }
    })
    console.log('utils.return userInfo==')
    console.log(loginUser)
    return loginUser;
  }
}

module.exports = loginUser;